package controller;

import java.io.IOException;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import dao.SuSheDao;

/**
 * Servlet implementation class U_Admin_SuSheServlet
 */
@WebServlet("/U_Admin_SuSheServlet")
public class U_Admin_SuSheServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public U_Admin_SuSheServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		boolean b = false; // 初始化返回值为 false
		String stuid = request.getParameter("id");
		String stuname = request.getParameter("name");
		String classroom = request.getParameter("classroom");
		//旧信息
		String oldroomid = request.getParameter("oldroomid");
		String oldid = request.getParameter("oldid"); 
		// 设置响应内容类型
		response.setContentType("text/html;charset=UTF-8");
		SuSheDao dao = new SuSheDao();
		//将数据写入数据库
		b=dao.daoAdminUpdateleave(stuid,stuname,classroom,oldroomid,oldid);
		//修改成功，弹出成功提示框
		if(b==true) { 
		// 跳转回原页面
		response.sendRedirect("View_SuShe/SuSheAdminMain.jsp");
		}else {
		System.out.print("请假清单修改失败 ");
		}
		}

}
